package wypozyczalnia.domain;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.hibernate.annotations.OnDelete;
import org.hibernate.annotations.OnDeleteAction;
import org.hibernate.annotations.Type;

@Entity
@Table(name = "hire")
public class Hire extends BaseEntity {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	private static final int NORMAL_LENGTH = 255;

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	@Column(updatable = false, name = "HIRE_ID")
	private Integer idHire;

	@Column(nullable = false)
	@Temporal(TemporalType.TIMESTAMP)
	private Date startDate;

	@Column(nullable = false)
	@Temporal(TemporalType.TIMESTAMP)
	private Date endDate;

	@Type(type = "org.hibernate.type.NumericBooleanType")
	@Column(nullable = false)
	private Boolean cancel;

	@ManyToOne
	@JoinColumn(name = "movie", nullable = false)
	@OnDelete(action = OnDeleteAction.CASCADE)
	private Movie movie;

	@ManyToOne
	@JoinColumn(name = "users", nullable = false)
	@OnDelete(action = OnDeleteAction.CASCADE)
	private User user;

	public Hire() {
	}

	public Hire(Date startDate, Date endDate, Boolean cancel, User user,
			Movie movie) {
		this.movie = movie;
		this.user = user;
		this.startDate = startDate;
		this.endDate = endDate;
		this.cancel = cancel;
	}

	public Integer getIdHire() {
		return idHire;
	}

	public void setIdHire(Integer idHire) {
		this.idHire = idHire;
	}

	public Date getStartDate() {
		return this.startDate;
	}

	public void setStartDate(Date startDate) {
		this.startDate = startDate;
	}

	public Date getEndDate() {
		return this.endDate;
	}

	public void setEndDate(Date endDate) {
		this.endDate = endDate;
	}

	public Boolean getCancel() {
		return cancel;
	}

	public void setCancel(Boolean cancel) {
		this.cancel = cancel;
	}

	public Movie getMovie() {
		return movie;
	}

	public void setMovie(Movie movie) {
		this.movie = movie;
	}

	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

}
